// 引入mysql
const conn = require("../../data");
module.exports.getUrl = (req, res) => {
  conn.query("select * from join_guide;", (err, data1) => {
    let arr = [];
    if (err) return console.log(err);
    console.log(data1);
    data1.forEach(element => {
      arr.push(element.page_id);
    });
    // console.log(data1Page_id)
    // 获取 文章表里的标题 链接 时间
    conn.query(
      `select * from page_news where page_options_id in(${[arr]});
        SELECT page_news.clickrate,page_news.id,page_news.title,FROM_UNIXTIME(page_news.created_at,'%Y.%m.%d %h:%i:%s') time FROM page_news  GROUP BY clickrate DESC limit 0,20 `,
      (err, data2) => {
        console.log(data2);
        res.json({ data1, data2 });
      }
    );
  });
};
